package com.shanyi.web.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.shanyi.common.result.ApiResult;
import com.shanyi.dao.req.AddCountReqDto;
import com.shanyi.dao.req.TravelInfoListReqDto;
import com.shanyi.dao.req.TravelInfoReqDto;
import com.shanyi.dao.resp.TravelInfoListRespDto;
import com.shanyi.service.biz.TravelBiz;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 旅行控制器
 *
 * @author shanyi
 * @date 2023/02/11
 **/
@RestController
@RequestMapping("/api/travel")
public class TravelController {
    private static final String LIST = "/list";
    private static final String ADD = "/add";
    private static final String DELETE = "/delete";
    private static final String UPDATE = "/update";
    private static final String ADD_COUNT = "/addCount";
    
    @Resource
    private TravelBiz travelBiz;
    
    @PostMapping(LIST)
    public ApiResult<IPage<TravelInfoListRespDto>> getTravelInfoList(@RequestBody TravelInfoListReqDto dto) {
        return ApiResult.success(travelBiz.getTravelInfoList(dto));
    }

    @PostMapping(ADD)
    public ApiResult<String> addTravelInfo(@RequestBody TravelInfoReqDto dto) {
        return ApiResult.success(travelBiz.addTravelInfo(dto));
    }

    @PostMapping(DELETE)
    public ApiResult<Object> deleteTravelInfo() {
        return ApiResult.success(travelBiz.deleteTravelInfo());
    }

    @PostMapping(UPDATE)
    public ApiResult<Object> updateTravelInfo() {
        return ApiResult.success(travelBiz.updateTravelInfo());
    }

    @PostMapping(ADD_COUNT)
    public ApiResult<String> addCount(@RequestBody AddCountReqDto dto) {
        return ApiResult.success(travelBiz.addCount(dto));
    }
}
